home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
STICK.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-08-27
|
21KB
|
469 lines
;STICK.COM for the IBM Personal Computer - 1987 by Jeff Prosise
; [d:][path]STICK [/L+|-] [/E+|-] [/B+|-] [/C-| fg bg]
bios_data segment at 40h
org 60h
bios_cursor dw ? ;cursor mode
org 63h
addr_6845 dw ? ;CRT Controller base address
org 87h
ega_info db ? ;EGA info byte
bios_data ends
;======================================================================
code segment para public 'code'
assume cs:code
org 100h
begin: jmp stick
copyright db "STICK 1.0 (c) 1987 Ziff Communications Co.",13,10,"$",1Ah
author db "Jeff Prosise"
locking db 0FFh ;state of cursor locking
emulation db 0FFh ;state of EGA cursor emulation
foreground db 0FFh ;selected foreground color
background db 0 ;selected background color
cursor_mode dw 0 ;desired cursor definition
adapter db 2 ;0=MDA or CGA, 1=EGA, 2=VGA
old_video label dword
old10h dw 0,0 ;interrupt 10h vector
;-----------------------------------------------------------------------------
;VideoInt intercepts calls to interrupt 10h.
;-----------------------------------------------------------------------------
VideoInt proc near
sti ;enable interrupts
cmp ah,6 ;check for scroll function
jb noscroll
cmp ah,7
ja pass
;
;Check the color selection for screen clear if color locking is on.
;
or al,al ;AL = 0 (clear screen)?
jne pass ;no, then pass thru to BIOS
test cs:[foreground],80h ;color locking active?
jnz pass ;no, then pass thru to BIOS
cmp bh,7 ;white-on-black?
jne pass ;no, then let it go
mov bh,cs:[background] ;reset attribute in BH
push cx
mov cl,4
shl bh,cl
pop cx
or bh,cs:[foreground]
pass: jmp old_video ;pass modified parm to BIOS
;
;See if the cursor mode is to be modified.
;
noscroll: cmp ah,1 ;cursor mode function?
jne pass ;no, then pass to BIOS
test ch,20h ;call to blank the cursor?
jnz pass ;yes, then pass to BIOS
;
;Alter the cursor definition in CX if cursor locking is on.
;
cmp cs:[locking],0FFh ;locking function active?
je nolock ;no, then check emulation function
push ax ;save registers
push cx
push dx
push es
mov cx,cs:[cursor_mode] ;get new cursor value
call SetCursorMode
pop es ;restore registers
pop dx
pop cx
pop ax
iret
;
;See if emulation should be performed.
;
nolock: cmp cs:[emulation],0FFh ;emulation function active?
je pass ;no, then pass control to BIOS
cmp cs:[adapter],1 ;EGA installed?
jne pass ;no, then pass control to BIOS
push ax ;save registers
push es
mov ax,bios_data ;make sure EGA is active
mov es,ax
assume es:bios_data
test es:[ega_info],8
jnz exit ;exit if it's not
test es:[ega_info],1 ;emulation bit set?
jnz exit ;yes, then exit
push bx ;save remaining registers
push cx
push dx
;
;Determine whether or not this call was intended for a CGA.
;
cmp cl,7 ;CGA-type cursor?
ja setmode ;no, then don't alter values
or cl,cl ;EGA ending line?
je setmode ;yes, then don't touch it
;
;Scale the starting and ending scan lines.
;
mov bx,cx ;transfer cursor mode to BX
mov ax,1130h ;determine bytes per character
int 10h ;points in CX
mov al,cl ;transfer points to al
dec al ;determine last scan line
sub al,bl ;calculate adjustment value
or bh,bh ;adjust starting scan line?
je endline ;not if it's zero
add bh,al ;adjust it
endline: add bl,al ;scale ending line
cmp bx,0C0Dh ;normal EGA underline cursor?
jne skip
mov bx,0B0Ch ;yes, then raise it a line
skip: inc bl ;adjust ending line for EGA
cmp bl,cl ;wrap around if necessary
jne nowrap
xor bl,bl
nowrap: or bx,bx ;full height cursor?
jne notfull
mov bl,1Eh ;adjust for full height
notfull: mov cx,bx ;transfer value back to CX
;
;Set the cursor and exit.
;
setmode: call SetCursorMode ;set the cursor
pop dx ;restore registers and exit
pop cx
pop bx
pop es
pop ax
iret
;
;Exit to the BIOS interrupt handling code.
;
exit: pop es ;exit to BIOS
pop ax
jmp cs:old_video
VideoInt endp
;-----------------------------------------------------------------------------
;SetCursorMode sets the cursor to the scan lines indicated in CX.
;-----------------------------------------------------------------------------
SetCursorMode proc near
mov ax,bios_data ;address BIOS data area with ES
mov es,ax
assume es:bios_data
mov es:[bios_cursor],cx ;store cursor mode
mov dx,es:[addr_6845] ;get CRTC address
mov al,10 ;out CH and CL to cursor registers
out dx,al
inc dx
mov al,ch
out dx,al
dec dx
mov al,11
out dx,al
inc dx
mov al,cl
out dx,al
ret
SetCursorMode endp
lastbyte equ $
;-----------------------------------------------------------------------------
;Stick routine receives control when the program is run.
;-----------------------------------------------------------------------------
line1 db 13,10,"Cursor Locking: $"
line2 db "Color Locking: $"
line3 db "Emulation Mode: $"
line4 db "EGA Emulation Bit: $"
errmsg db 13,10,"Usage: [d:][path]STICK [/L+|-] [/E+|-] "
db "[/B+|-] [/C-| fg bg]",13,10,"$"
on db "On",13,10,"$"
off db "Off",13,10,"$"
bitvalue db "0",13,10,"$"
stick proc near
assume cs:code,ds:code,es:code,ss:code
;
;Determine what type of video adapter is installed.
;
mov ax,1A00h ;look for a VGA
int 10h
cmp al,1Ah